﻿Imports System
Imports System.Xml
Imports Searching_Airlines
Imports System.Drawing.Point

Public Class Componen

    Dim urut As Integer = 0
    Dim coba As Airlines = New Airlines()
    Dim kode As String = ""
    Dim ling As String = ""
    Dim posi As Point
    Dim tik As Integer = 0

    Private Sub international_Click(sender As Object, e As EventArgs) Handles international.Click
        international.Visible = False
        domestik.Visible = True
        tipe_penerbangan.Text = "international"

        Timer.Enabled = True
        Timer1.Enabled = False
        hasil.Text = ""
        hasil.Location = New Point(500, hasil.Location.Y)
    End Sub

    Private Sub domestik_Click(sender As Object, e As EventArgs) Handles domestik.Click
        domestik.Visible = False
        international.Visible = True
        tipe_penerbangan.Text = "domestic"

        Timer.Enabled = True
        Timer1.Enabled = False
        hasil.Text = ""
        hasil.Location = New Point(500, hasil.Location.Y)
    End Sub

    Private Sub kedatangan_Click(sender As Object, e As EventArgs) Handles kedatangan.Click
        kedatangan.Visible = False
        keberangkatan.Visible = True
        datang_pergi.Text = "departure"

        Timer.Enabled = True
        Timer1.Enabled = False
        hasil.Text = ""
        hasil.Location = New Point(500, hasil.Location.Y)
    End Sub

    Private Sub keberangkatan_Click(sender As Object, e As EventArgs) Handles keberangkatan.Click
        keberangkatan.Visible = False
        kedatangan.Visible = True
        datang_pergi.Text = "arrival"

        Timer.Enabled = True
        Timer1.Enabled = False
        hasil.Text = ""
        hasil.Location = New Point(500, hasil.Location.Y)
    End Sub

    Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick
        Dim domint, depar As String
        Dim syarat As Boolean = False

        domint = tipe_penerbangan.Text
        depar = datang_pergi.Text

        If searching.Text = "" Then
            nama_bandara.Text = "All Airlines"
            searching.Text = "--Searching Airlines--"
            kode = "--"
            hasil.Text = coba.GetFlight(domint, depar, kode, waiting.Text)
        Else
            kode = searching.Text.Substring(searching.Text.Length - 2)
            hasil.Text = coba.GetFlight(domint, depar, kode, waiting.Text)
        End If
        
        If hasil.Text = "" Then
            hasil.Text = "No Flight Schedule.."
            hasil.ForeColor = Color.White
        Else
            hasil.ForeColor = Color.Black
        End If

        Timer.Enabled = False
        Timer1.Enabled = True
        hasil.Location = New Point(500, hasil.Location.Y)

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        tik = tik + 1

        If tik = 700 Then
            hasil.Text = hasil.Text & "---" & hasil.Text
        End If

        hasil.Location = New Point(hasil.Location.X - 10, hasil.Location.Y)
        posi = hasil.Location

    End Sub

    Private Sub searching_KeyDown(sender As Object, e As KeyEventArgs) Handles searching.KeyDown

        If e.KeyCode = Keys.Enter Then
            nama_bandara.Text = searching.Text

            Timer.Enabled = True
            Timer1.Enabled = False
            hasil.Text = ""
            hasil.Location = New Point(500, hasil.Location.Y)
        End If

    End Sub

    Private Sub searching_MouseClick(sender As Object, e As MouseEventArgs) Handles searching.MouseClick
        searching.Clear()
    End Sub

    Private Sub waiting_KeyPress(sender As Object, e As KeyPressEventArgs) Handles waiting.KeyPress
        e.KeyChar = Chr(0)
    End Sub

    Private Sub waiting_SelectedIndexChanged(sender As Object, e As EventArgs) Handles waiting.SelectedIndexChanged
        Timer.Enabled = True
        Timer1.Enabled = False
        hasil.Text = ""
        hasil.Location = New Point(500, hasil.Location.Y)
    End Sub

    Private Sub Panel_Paint(sender As Object, e As PaintEventArgs) Handles Panel.Paint

    End Sub
End Class
